/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package com.kenny.wiki.ejb.entity.facade;

import com.kenny.wiki.ejb.entity.facade.remote.CategoryFacadeRemote;
import com.kenny.wiki.ejb.entity.Category;
import java.util.List;
import javax.ejb.Stateless;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;

/**
 *
 * @author Kenny Lin
 */
@Stateless
public class CategoryFacade extends AbstractFacade<Category> implements CategoryFacadeRemote {
    @PersistenceContext(unitName = "Kenny-Wiki-ejbPU")
    private EntityManager em;

    protected EntityManager getEntityManager() {
        return em;
    }

    public CategoryFacade() {
        super(Category.class);
    }

    public Category findByCategoryName(String categoryName){
        return (Category)getEntityManager().createNamedQuery("Category.findByCategoryName")
                .setParameter("categoryName", categoryName).getSingleResult();
    }

}
